﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Shapes;

namespace FourPartHarmony2
{
    /// <summary>
    /// WindowTempo.xaml の相互作用ロジック
    /// </summary>
    public partial class WindowTempo : Window
    {
        //private Glass glass;

        public int Tempo { get; set; }

        public WindowTempo(int tempo) {
            InitializeComponent();
            Tempo = tempo;
            textBox1.Text = string.Format("{0}", tempo);
        }

        private void Window_Loaded(object sender, RoutedEventArgs e) {
            //glass = new Glass(this, 0);
            //glass.Apply();
        }

        private void button1_Click(object sender, RoutedEventArgs e) {
            DialogResult = true;
            Close();
        }

        private void textBox1_TextChanged(object sender, TextChangedEventArgs e) {
            int result;
            if (Int32.TryParse(textBox1.Text, out result)) {
                if (result <= 0) {
                    result = 1;
                } else if (255 < result) {
                    result = 255;
                } else {
                    if (Tempo == result) {
                        return;
                    }
                }
            } else {
                result = Tempo;
            }
            Tempo = result;
            textBox1.Text = string.Format("{0}", Tempo);
            System.Console.WriteLine("{0}", Tempo);
        }
    }
}
